package liangtWorkSpace.base.ifElse;

import liangtWorkSpace.base.ifElse.command.AddCommand;
import liangtWorkSpace.base.ifElse.command.Command;
import liangtWorkSpace.base.ifElse.myEnum.OperatorEnum;
import liangtWorkSpace.base.ifElse.rule.Expression;
import liangtWorkSpace.base.ifElse.rule.Result;
import liangtWorkSpace.base.ifElse.rule.RuleEngine;
import liangtWorkSpace.base.ifElse.service.Calculator;
import org.junit.jupiter.api.Test;

/**
 * @ClassName Propertie
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/5/15 12:56
 */
public class Propertie {
    @Test
    public void whenCalculateUsingEnumOperator_thenReturnCorrectResult() {
        Calculator calculator = new Calculator();
        int result = calculator.calculate(3, 4, OperatorEnum.valueOf("ADD"));
        System.out.println(result);
    }


    @Test
    public void whenCalculateUsingCommand_thenReturnCorrectResult() {
        Calculator calculator = new Calculator();
        int result = calculator.calculate(new AddCommand(3, 7));
        System.out.println(result);
    }

    @Test
    public void whenNumbersGivenToRuleEngine_thenReturnCorrectResult() {
        Expression expression = new Expression(5, 5, OperatorEnum.ADD);
        RuleEngine engine = new RuleEngine();
        Result result = engine.process(expression);
        System.out.println(result.getValue());
    }
}
